package com.runa.monitor.platinterface.extend.third.newester.pojo;


import java.io.Serializable;

public class AjaxResponse implements Serializable {
    private int code;
    private Object resultInfo;
    private String message;

    public AjaxResponse() {
    }


    public AjaxResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }


    public Object getResultInfo() {
        return resultInfo;
    }

    public void setResultInfo(Object resultInfo) {
        this.resultInfo = resultInfo;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }


    /**
     * 静态构造器
     *
     * @param responseCode 响应编码
     * @return 构造器对象
     */
    public static AjaxResponse of(ResponseCode responseCode) {
        AjaxResponse vo = new AjaxResponse();
        vo.code = responseCode.code();
        vo.message = responseCode.message();
        return vo;
    }

    /**
     * 静态构造器
     *
     * @param resultInfo 返回结果
     * @return 构造器对象
     */
    public static AjaxResponse of(Object resultInfo) {
        AjaxResponse vo = new AjaxResponse();
        vo.resultInfo = resultInfo;
        vo.code = ResponseCode.SUCCESS.code();
        vo.message = ResponseCode.SUCCESS.message();
        return vo;
    }

    /**
     * 静态构造器
     *
     * @param code    code
     * @param message message
     * @return 构造器对象
     */
    public static AjaxResponse of(int code, String message) {
        AjaxResponse vo = new AjaxResponse();
        vo.code = code;
        vo.message = message;
        return vo;
    }

    /**
     * 设定响应编码
     *
     * @param responseCode 响应编码
     * @return 构造器对象
     */
    public AjaxResponse code(ResponseCode responseCode) {
        this.code = responseCode.code();
        this.message = responseCode.message();
        return this;
    }

    /**
     * 设定响应编码
     *
     * @param responseCode 响应编码
     * @return 构造器对象
     */
    public static AjaxResponse of(ResponseCode responseCode, Object resultInfo) {
        AjaxResponse vo = new AjaxResponse();
        vo.code = responseCode.code();
        vo.message = responseCode.message();
        vo.resultInfo = resultInfo;
        return vo;
    }

    /**
     * 设定返回结果
     *
     * @param resultInfo 返回结果
     * @return 构造器对象
     */
    public AjaxResponse resultInfo(Object resultInfo) {
        this.resultInfo = resultInfo;
        return this;
    }

    /**
     * 静态构造器
     *
     * @param code    code
     * @param message message
     * @return 构造器对象
     */
    public static AjaxResponse of(int code, String message, Object resultInfo) {
        AjaxResponse vo = new AjaxResponse();
        vo.code = code;
        vo.message = message;
        vo.resultInfo = resultInfo;
        return vo;
    }

    @Override
    public String toString() {
        return "AjaxResponse{" + "code=" + code + ",  resultInfo=" + resultInfo + ", message='" + message + '\'' + '}';
    }
}

